package com.nextbusmn.server.services;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.labs.repackaged.org.json.JSONException;
import com.google.appengine.labs.repackaged.org.json.JSONObject;

public class ErrorService implements AndroidService {
	
	private HttpServletResponse response;
	private String requestData;
	
//	public ErrorService(HttpServletRequest request, HttpServletResponse response) {
//		this.requestData = request.getQueryString();
//		this.response = response;
//	}
	
	public ErrorService(String request, HttpServletResponse response) {
		this.requestData = request;
		this.response = response;
	}
	@Override
	public void processRequest() {
		JSONObject jsonError = new JSONObject();
		try {
			jsonError.put("error", requestData);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		
		response.setContentType("application/json");
        response.setHeader("Cache-Control", "no-cache");
        try {
			response.getWriter().write(jsonError.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
